﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntitiesGenerator
{
    /// <summary>
    /// 别问我为什么不用文本模板,因为任性
    /// </summary>
    public static class EntityTemplateConst
    {
        /// <summary>
        /// 实体类模板字符串
        /// </summary>
        public static readonly string EntityTemplate =
@"using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;

namespace {NameSpace}
{
    /// <summary>
    /// {TableRemark}
    /// </summary>
    [Table(""{TableName}"")]
    public partial class {TableName}{BaseType}
    {
{Properties}
    }
}
";

        public static readonly string DbContextTemplate =
@"using System.Data.Entity;

namespace {NameSpace}
{
    public class {ContextName} : DbContext
    {
        public {ContextName}() : base(""Default"")
        {
            this.Configuration.AutoDetectChangesEnabled = false;
            this.Configuration.LazyLoadingEnabled = false;
            this.Configuration.ProxyCreationEnabled = false;
        }
{Properties}

    }
}
";
        /// <summary>
        /// 主键注解
        /// </summary>
        public static readonly string PrimaryKey = "\t\t[Key]";
        /// <summary>
        /// 主键注解,包含列顺序,需要order参数
        /// </summary>
        public static readonly string PrimaryKeyContainOrder = "\t\t[Key, Column(Order = {0})]";
        /// <summary>
        /// 数据列为自增
        /// </summary>
        public static readonly string DatabaseGeneratedIdentity = "\t\t[DatabaseGenerated(DatabaseGeneratedOption.Identity)]";
        /// <summary>
        /// 数据列无需自动生成
        /// </summary>
        public static readonly string DatabaseGeneratedNone = "\t\t[DatabaseGenerated(DatabaseGeneratedOption.None)]";
        /// <summary>
        /// 必须字段
        /// </summary>
        public static readonly string Required = "\t\t[Required]";
        /// <summary>
        /// 外键信息,需要参数外键列名
        /// </summary>
        public static readonly string ForeignKey = "\t\t[ForeignKey(\"{0}\")]";
        /// <summary>
        /// 字段长度,需要参数 长度
        /// </summary>
        public static readonly string StringLength = "\t\t[StringLength({0})]";
        /// <summary>
        /// 字段备注,需要参数 备注
        /// </summary>
        public static readonly string Remark = @"
        /// <summary>
        /// {0}
        /// </summary>";

        /// <summary>
        /// 输出窗口消息的 输出源名称
        /// </summary>
        public static readonly string OuputPanelName = "EntitiesGenerator";

        /// <summary>
        /// DbContext属性字符串
        /// </summary>
        public static readonly string ContextProperty = "\t\tpublic IDbSet<{0}> {0} {{ get; set; }}";

    }
}
